#define _CRT_SECURE_NO_WARNINGS 1
#include"Sort.h"

void SortTest()
{
	srand((unsigned int)time(0));
	int n = 100000;
	int* a = (int*)malloc(sizeof(int) * n);
	int* b = (int*)malloc(sizeof(int) * n);
	int* c = (int*)malloc(sizeof(int) * n);
	int* d = (int*)malloc(sizeof(int) * n);
	int* e = (int*)malloc(sizeof(int) * n);
	int* f = (int*)malloc(sizeof(int) * n);
	int* g = (int*)malloc(sizeof(int) * n);
	int* h = (int*)malloc(sizeof(int) * n);






	if (a == NULL||b==NULL||c==NULL||d==NULL||e==NULL||f==NULL||g==NULL||h==NULL)
		return;

	for (int i = 0; i < n; i++)
	{
		a[i] = rand();
		b[i] = a[i];
		c[i] = a[i];
		d[i] = a[i];
		e[i] = a[i];
		f[i] = a[i];
		g[i] = a[i];
		h[i] = a[i];
	}

	int begin1 = clock();
	//InsertSort(a, n);
	int end1 = clock();
	printf("InsertSort Time is: %d", end1 - begin1);
	printf("\n");

	int begin2 = clock();
	//ShellSort(b, n);
	int end2 = clock();
	printf("ShellSort Time is: %d", end2 - begin2);
	printf("\n");

	int begin3 = clock();
	//SelectSort(c, n);
	int end3 = clock();
	printf("SelectSort Time is: %d", end3 - begin3);
	printf("\n");

	int begin4 = clock();
	//BubbleSort(d, n);
	int end4 = clock();
	printf("BubbleSort Time is: %d", end4 - begin4);
	printf("\n");

	int begin5 = clock();
    HeapSort(e, n);
	int end5 = clock();
	printf("HeapSort Time is: %d", end5 - begin5);
	printf("\n");

	int begin6 = clock();
	HoleSort(f,0, n-1);
	int end6 = clock();
	printf("HoleSort Time is: %d", end6 - begin6);
	printf("\n");


	int begin7 = clock();
	QuickSort(g, 0 ,n - 1);
	int end7 = clock();
	printf("QuickSort  Time is: %d", end7 - begin7);
	printf("\n");

	int begin8 = clock();
	CountSort(g,  n - 1);
	int end8 = clock();
	printf("CountSort  Time is : %d", end8 - begin8);
	printf("\n");


	free(a);
	free(b);
	free(c);
	free(d);
	free(e);
	free(f);
	free(g);
}

void ShellSortTest()
{
	int a[] = { 10,9,8,7,6,5,4,3,2,1 };
	_Printf(a, sizeof(a) / sizeof(int));
	ShellSort(a, sizeof(a) / sizeof(int));
	_Printf(a, sizeof(a) / sizeof(int));
}

void SelectSortTest()
{
	int a[] = { 10,9,0,-11,8,7,6,5,4,3,3,2,1 };
	_Printf(a, sizeof(a) / sizeof(int));
	SelectSort(a, sizeof(a) / sizeof(int));
	_Printf(a, sizeof(a) / sizeof(int));
}

void BubbleSortTest()
{
	int a[] = { 10,9,0,-11,8,7,6,5,4,3,3,2,1 };
	_Printf(a, sizeof(a) / sizeof(int));
	BubbleSort(a, sizeof(a) / sizeof(int));
	_Printf(a, sizeof(a) / sizeof(int));
}

void HeapSortTest()
{
	int a[] = { 10,9,0,-11,8,7,6,5,4,3,3,2,1 };
	_Printf(a, sizeof(a) / sizeof(int));
	HeapSort(a, sizeof(a) / sizeof(int));
	_Printf(a, sizeof(a) / sizeof(int));
}

void QuickSortTest()
{
	int a[] = { 1,9,50,3,6,-5,5,2,23,0 };
	_Printf(a, sizeof(a) / sizeof(int));
	QuickSort(a, 0,sizeof(a) / sizeof(int)-1);
	_Printf(a, sizeof(a) / sizeof(int));
}




void HoleSortTest()
{
	int a[] = { 1,9,50,3,6,-5,5,2,23,0 };
	_Printf(a, sizeof(a) / sizeof(int));
	HoleSort(a, 0, sizeof(a) / sizeof(int) - 1);
	_Printf(a, sizeof(a) / sizeof(int));
}

void QuickSortNonRTest()
{
	int a[] = { 1,9,50,3,6,-5,5,2,23,0 };
	_Printf(a, sizeof(a) / sizeof(int));
	QuickSortNonR(a, 0, sizeof(a) / sizeof(int) - 1);
	_Printf(a, sizeof(a) / sizeof(int));
}

void MergeSortTest()
{
	int a[] = { 1,9,50,3,6,-5,5,2,23,0 };
	_Printf(a, sizeof(a) / sizeof(int));
	MergeSort(a, 0, sizeof(a) / sizeof(int) - 1);
	_Printf(a, sizeof(a) / sizeof(int));
}

void MergeSortNonRTest()
{	
	int a[] = { 1,9,50,3,6,-5,5,2,8,10,5,5,5,5};
	_Printf(a, sizeof(a) / sizeof(int));
	MergeSortNonR(a, 0, sizeof(a) / sizeof(int) - 1);
	_Printf(a, sizeof(a) / sizeof(int));
}

void QuickSort2Test()
{
	int a[] = { 1,9,50,3,6,-5,5,2,8,10,5,5,5,5 };
	_Printf(a, sizeof(a) / sizeof(int));
	QuickSort2(a, 0, sizeof(a) / sizeof(int) - 1);
	_Printf(a, sizeof(a) / sizeof(int));
}

void CountSortTest()
{
	int a[] = { 1,9,50,3,6,-5,5,2,8,10,5,5,5,5 };
	_Printf(a, sizeof(a) / sizeof(int));
	CountSort(a,sizeof(a) / sizeof(int) - 1);
	_Printf(a, sizeof(a) / sizeof(int));
}

int main()
{
	srand((unsigned int)time(0));

	SortTest();

	//ShellSortTest();
	//SelectSortTest();
	//BubbleSortTest();
	//HeapSortTest();
	//QuickSortTest();
	//HoleSortTest();
	//QuickSortNonRTest();
	//QuickSort2Test();
	//MergeSortTest();
	//MergeSortNonRTest();

	//CountSortTest();
	 	return 0;
}